package com.ruoyi.web.controller.kiku;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.kiku.domain.KikuDeeds;
import com.ruoyi.kiku.service.IKikuDeedsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 小鞠事迹Controller
 *
 * @author ruoyi
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/kiku/deeds")
public class KikuDeedsController extends BaseController
{
    @Autowired
    private IKikuDeedsService kikuDeedsService;

    /**
     * 查询小鞠事迹列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:deeds:list')")
    @GetMapping("/list")
    public TableDataInfo list(KikuDeeds kikuDeeds)
    {
        startPage();
        List<KikuDeeds> list = kikuDeedsService.selectKikuDeedsList(kikuDeeds);
        return getDataTable(list);
    }

    /**
     * 导出小鞠事迹列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:deeds:export')")
    @Log(title = "小鞠事迹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KikuDeeds kikuDeeds)
    {
        List<KikuDeeds> list = kikuDeedsService.selectKikuDeedsList(kikuDeeds);
        ExcelUtil<KikuDeeds> util = new ExcelUtil<KikuDeeds>(KikuDeeds.class);
        util.exportExcel(response, list, "小鞠事迹数据");
    }

    /**
     * 获取小鞠事迹详细信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:deeds:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kikuDeedsService.selectKikuDeedsById(id));
    }

    /**
     * 新增小鞠事迹
     */
    @PreAuthorize("@ss.hasPermi('kiku:deeds:add')")
    @Log(title = "小鞠事迹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KikuDeeds kikuDeeds)
    {
        return toAjax(kikuDeedsService.insertKikuDeeds(kikuDeeds));
    }

    /**
     * 修改小鞠事迹
     */
    @PreAuthorize("@ss.hasPermi('kiku:deeds:edit')")
    @Log(title = "小鞠事迹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KikuDeeds kikuDeeds)
    {
        return toAjax(kikuDeedsService.updateKikuDeeds(kikuDeeds));
    }

    /**
     * 删除小鞠事迹
     */
    @PreAuthorize("@ss.hasPermi('kiku:deeds:remove')")
    @Log(title = "小鞠事迹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kikuDeedsService.deleteKikuDeedsByIds(ids));
    }
}
